﻿using System;
using System.Collections.Generic;
using System.Text;
using Model.Entities_EF;

namespace Model
{
    /// <summary>
    /// 单例模式的实现   暂无使用
    /// </summary>
    public class SqlContext
    {
        private readonly RSServerSettingsModel _rsServerSettingsModel;
        // 定义一个静态变量来保存类的实例
        private static ICPrkmonitorContext _ICPrkmonitorContext;
        // 定义一个标识确保线程同步
        private static readonly object locker = new object();
        public SqlContext(RSServerSettingsModel rsServerSettingsModel)
        {
            _rsServerSettingsModel = rsServerSettingsModel;
        }
        public  ICPrkmonitorContext GetICPrkmonitorContext
        {
            get
            {
                if (_ICPrkmonitorContext == null)
                {
                    lock (locker)
                    {
                        // 如果类的实例不存在则创建，否则直接返回
                        if (_ICPrkmonitorContext == null)
                        {
                            _ICPrkmonitorContext = new ICPrkmonitorContext(_rsServerSettingsModel);
                        }
                    }
                }
                return _ICPrkmonitorContext;
            }
        }
    }

}
